`
https://leetcode.cn/problems/sort-characters-by-frequency/
`

/**
 * @param {string} s
 * @return {string}
 */
var frequencySort = function (s) {
  const counter = {}
  for (const c of s) {
    counter[c] = (counter[c] || 0) + 1
  }

  return Object.entries(counter)
    .sort((a, b) => b[1] - a[1])
    .map(([char, count]) => char.repeat(count))
    .join('')
};